CFLAGS=-m64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_BSD_SOURCE -D_POSIX_SOURCE -lm -fno-math-errno -Wall
OFLAGS = -O3 -std=c99
DEBUGFLAGS = -g -O2 -std=c99
PROFFLAGS = -g -pg -O2 -std=c99
CC = gcc
CFILES = rockstar.c check_syscalls.c fof.c groupies.c subhalo_metric.c potential.c nfw.c config_vars.c config.c io/read_config.c client.c server.c merger.c inet/socket.c inet/address.c io/meta_io.c io/io_ascii.c io/stringparse.c io/io_gadget.c io/io_art.c io/io_bgc2.c io/io_util.c

all:
	@make reg EXTRA_FLAGS="$(OFLAGS)"

debug:
	@make reg EXTRA_FLAGS="$(DEBUGFLAGS)"

prof:
	@make reg EXTRA_FLAGS="$(PROFFLAGS)"

dist:
	cd ../ ; tar -czvf rockstar.tar.gz Rockstar/Makefile Rockstar/*.[ch] Rockstar/*/*.[ch] Rockstar/quickstart.cfg Rockstar/parallel.cfg Rockstar/scripts/sample.pbs Rockstar/scripts/bolshoi.cfg Rockstar/SOURCE_LAYOUT Rockstar/README Rockstar/LICENSE; mv rockstar.tar.gz Rockstar

reg:
	$(CC) $(CFLAGS) main.c $(CFILES) -o rockstar  $(EXTRA_FLAGS)

bgc2:
	$(CC) $(CFLAGS) util/redo_bgc2.c $(CFILES) -o util/redo_bgc2  $(OFLAGS)

substats:
	$(CC) $(CFLAGS) util/subhalo_stats.c $(CFILES) -o util/subhalo_stats  $(OFLAGS)


clean:
	rm -f *~ io/*~ inet/*~ util/*~ rockstar util/redo_bgc2 util/subhalo_stats

